﻿#ifndef DIALOG_H
#define DIALOG_H

#include <head/g_pch.h>
#include "baiduspeechsynthesizer.h"

#ifdef Q_OS_WIN32
#pragma message("ONLY FOR LINUX NOW")
#else
#include "element/cdb.h"
#include <AVPlayer.h>
#endif

using namespace QtAV;

namespace Ui {
class Dialog;
}

class Dialog : public QDialog
{
    Q_OBJECT

public:
    explicit Dialog(QWidget *parent = 0);
    ~Dialog();

    void startSpeechSynthesizer();
    void stopSpeechSynthesizer();

    void onErrorMsg(const QString &msg);
    void onSynthesisFinished(const QString &text,
                             const QString &fileName);

    void play(const QString &fileName);

signals:
    void synthesis(const QString &text);

private slots:
    void on_btn_submit_clicked();

    void on_btn_ask_clicked();

    void on_btn_syn_clicked();

private:
    Ui::Dialog *ui;

    QHash<QString,QString> cache;
    CDB cdb;
    AVPlayer *player;
    BaiduSpeechSynthesizer *synthesizer;
    QThread synthesizerThread;
};

#endif // DIALOG_H
